package com.wgh.api.client.pay;

import com.wgh.api.client.fallback.PayClientFallback;
import com.wgh.pay.dto.PayDTO;
import com.wgh.pay.dto.RefundDTO;
import com.wgh.pay.dto.PayChannelConfigDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 支付服务客户端接口
 */
@FeignClient(name = "shop-pay", fallback = PayClientFallback.class)
public interface PayClient {

    /**
     * 创建支付订单
     */
    @PostMapping("/api/pay/create")
    Map<String, Object> createPayOrder(@RequestBody Map<String, Object> params);

    /**
     * 查询支付订单状态
     */
    @GetMapping("/api/pay/query/{orderId}")
    Map<String, Object> queryPayOrderStatus(@PathVariable("orderId") Long orderId);

    /**
     * 支付结果通知（异步回调）
     */
    @PostMapping("/api/pay/notify/{payType}")
    String payNotify(@PathVariable Integer payType, 
                     @RequestBody(required = false) Map<String, String> notifyData, 
                     @RequestParam(required = false) Map<String, String> queryParams);

    /**
     * 关闭支付订单
     */
    @PostMapping("/api/pay/close/{orderId}")
    Map<String, Object> closePayOrder(@PathVariable("orderId") Long orderId);

    /**
     * 发起退款
     */
    @PostMapping("/api/pay/refund")
    Map<String, Object> refund(@RequestBody Map<String, Object> params);

    /**
     * 查询退款状态
     */
    @GetMapping("/api/pay/refund/query/{orderId}")
    Map<String, Object> queryRefundStatus(@PathVariable("orderId") Long orderId);

    /**
     * 获取支付渠道配置
     */
    @GetMapping("/api/pay/config/{payType}")
    Map<String, Object> getPayChannelConfig(@PathVariable("payType") Integer payType);

    /**
     * 统一支付接口
     */
    @PostMapping("/api/pay/unified")
    Map<String, Object> unifiedPay(@RequestBody Map<String, Object> payParams);
}